Skip to content

Comments

feat(http): implement token refresh mechanism and JWT invalidation in new http feature#32

Merged
marfavi merged 9 commits intomainfrom
om-refresh-tokens
Feb 23, 2026
Merged

feat(http): implement token refresh mechanism and JWT invalidation in new http feature#32
marfavi merged 9 commits intomainfrom
om-refresh-tokens

Conversation

@marfavi
Copy link
Member

@marfavi marfavi commented Feb 23, 2026

Description

This PR adds a token refresh mechanism to the http layer so expired JWTs are renewed transparently, without requiring the user to log in again. There is a cyclic dependency between the token refresher and AuthCubit (which handles logout logic), so this is fixed with an AuthCubitHandle.

HTTP-related files are now moved into a dedicated http/ feature folder.

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore
  • 🧪 Test

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a token refresh mechanism for the HTTP layer, allowing expired JWTs to be automatically renewed without requiring user re-login. It also reorganizes HTTP-related files into a dedicated http/ feature folder and introduces a cyclic dependency breaking pattern using AuthCubitHandle.

Changes:

  • Implements TokenRefreshAuthenticator to automatically refresh expired JWTs on 401 responses and retry failed requests
  • Adds AuthCubitHandle to break the cyclic dependency between HTTP layer and authentication logic
  • Introduces a debug-only JWT invalidation feature for testing token refresh behavior
  • Reorganizes HTTP components into a dedicated feature folder with a barrel export file

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
lib/http/http.dart New barrel file exporting HTTP-related modules and generated API clients
lib/http/make_http_client.dart Factory function creating configured ChopperClient with authenticator and interceptor
lib/http/network_request_interceptor.dart Updated to use extracted AuthTokenStore; added documentation
lib/http/network_request_executor.dart Updated import to use new http barrel file
lib/http/token_refresh_authenticator.dart New authenticator implementing automatic token refresh on 401 responses
lib/login/bloc/auth_cubit_handle.dart New handle class breaking cyclic dependency between HTTP and auth layers
lib/login/bloc/authentication_cubit.dart Removed unimplemented refreshToken method
lib/login/data/auth_token_store.dart Extracted from network_request_interceptor into separate file with documentation
lib/login/data/authentication_token_repository.dart Added invalidateJwt method for debug testing and updated import
lib/login/data/authentication_tokens.dart Added toString method for debugging
lib/login/data/login_repository.dart Updated imports to use http barrel file
lib/core/failures.dart Fixed field name typo (statuscode → statusCode) and improved error messages
lib/core/widgets/app_bar.dart Added debug-only button to invalidate JWT tokens for testing
lib/app/dependencies_provider.dart Updated dependency wiring to support token refresh architecture
lib/tickets/my_tickets/data/owned_tickets_remote_data_provider.dart Updated imports to use http barrel file
test/router_test.dart Updated imports to use http barrel file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@marfavi marfavi merged commit 1240bc0 into main Feb 23, 2026
3 checks passed
@marfavi marfavi deleted the om-refresh-tokens branch February 23, 2026 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant